package com.jiepu.daily.corejava.advanceed.part7io;

import java.io.File;
import java.net.URL;

/**
 * @Description:
 * @author: xinjie.txt
 * @date: 2020/8/4  14:34
 */
public class FileDemo2 {

	public static void main(String[] args) {

		File file1 = new File("E:\\workspace-javaee-web\\CourseTest\\src\\com\\jiepu\\daily\\advanceed\\part7_io\\xinjie.txt");
		System.out.println(file1.exists()); // true

		File file2 = new File("src/com/jiepu/daily/advanceed/part7_io/xinjie.txt");
		System.out.println(file2.exists()); // true

		File file4 = new File("bin/com/jiepu/daily/advanceed/part7_io/xinjie.txt");
		System.out.println(file4.exists()); // true

		File file3 = new File("jiepu/daily/advanceed/part7_io/xinjie.txt");
		System.out.println(file3.exists()); // false

		System.out.println("-------------------------");

		Class cls = FileDemo2.class;
		URL url = cls.getResource("/");
		String loadPath = url.getPath();
		File file6 = new File(loadPath);
		System.out.println(url);
		System.out.println(loadPath);
		System.out.println(file6);
		System.out.println(file6.exists());

		System.out.println();
		System.out.println();
		System.out.println();


		String filePath = FileDemo2.class.getResource("/com/jiepu/daily/corejava/advanceed/part7io/xinjie.txt").getPath();
		File file5 = new File(filePath);
		System.out.println(file5);
		System.out.println(file5.exists()); // true


	} // main
}
